package router

import (
	"github.com/gin-gonic/gin"
	"userCRUD/controllers"
	"userCRUD/logger"
	"userCRUD/middleware"
)

func Setup() *gin.Engine {
	r := gin.New()
	r.Use(logger.GinLogger(), logger.GinRecovery(true), middleware.Cors)
	apiGroup := r.Group("/api")

	userRouter(apiGroup)

	r.NoRoute(func(c *gin.Context) {
		controllers.ResponseError(c, controllers.ErrorNotFound)
	})

	return r
}
